package proxypattern.impl;


import proxypattern.base.BaseRemote;

import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author yaojianfeng
 * 远程服务实现
 * 想要创建一个远程对象,扩展UnicastRemoteObject是最容易的方法
 */
public class MyRemoteImpl extends UnicastRemoteObject implements BaseRemote {

    public MyRemoteImpl() throws RemoteException {
    }

    public MyRemoteImpl(int port) throws RemoteException {
        super(port);
    }

    public MyRemoteImpl(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
        super(port, csf, ssf);
    }

    /**
     * 远程接口
     *
     * @return 字符串(json)
     * @throws RemoteException 远程调用异常
     */
    @Override
    public String sayHello() throws RemoteException {
        return "Server says,'Hey SB250' ";
    }


}
